package cn.pupil.design;

import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: 测试验证
 * @Author: pupil
 * @Date: 2024/06/23 下午 10:51
 */
public class ApiTest {

    private Logger logger = LoggerFactory.getLogger(ApiTest.class);

    @Test
    public void test_bankCard() {
        logger.info("里氏替换前，CashCard类：");
        CashCard bankCard = new CashCard("800999898", "2024-06-23");
        // 提现
        bankCard.withdrawal("14451", new BigDecimal(100));
        // 储蓄
        bankCard.recharge("14451", new BigDecimal(100));

        logger.info("里氏替换后，CreditCard类：");
        CashCard creditCard = new CreditCard("800999898", "2024-06-23");
        // 提现
        creditCard.withdrawal("14451", new BigDecimal(1000000));
        // 储蓄
        creditCard.recharge("14451", new BigDecimal(100));

        // 交易流水
        List<String> tradeFlow = bankCard.tradeFlow();
        logger.info("查询交易流水，{}", JSON.toJSONString(tradeFlow));
    }

    @Test
    public void test_CreditCard(){
        CreditCard creditCard = new CreditCard("800999898", "2024-06-23");
        // 支付，贷款
        creditCard.loan("14451", new BigDecimal(100));
        // 还款
        creditCard.repayment("14451", new BigDecimal(100));

        // 交易流水
        List<String> tradeFlow = creditCard.tradeFlow();
        logger.info("查询交易流水，{}", JSON.toJSONString(tradeFlow));
    }
}
